<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<link th:href="@{/assets/css/bootstrap.min.css}" rel="stylesheet" />
<link rel="stylesheet" th:href="@{/assets/css/font-awesome.min.css}" />
<link rel="stylesheet" th:href="@{/assets/css/font-awesome-ie7.min.css}" />
<link rel="stylesheet" th:href="@{/assets/css/jquery-ui-1.10.3.custom.min.css}" />
<link rel="stylesheet" th:href="@{/assets/css/colorbox.css}" />
<link th:href="@{/assets/css/ace.min.css}" rel="stylesheet" type="text/css"/>
<link th:href="@{/assets/css/ace-rtl.min.css}" rel="stylesheet" type="text/css"/>
<link th:href="@{/assets/css/ace-skins.min.css}" rel="stylesheet" type="text/css"/>
<link rel="stylesheet" type="text/css" th:href="@{/My97DatePicker/skin/WdatePicker.css}"/>
<link rel="stylesheet" th:href="@{/assets/css/chosen.css}" />
<head th:include="fragments/head::header" />
<style>
	.error {
		color: #F00
	}

	.input-unit{
		width: 65px;
		height: 25px;
		display: block;
		float: left;
		background-color: #abbac3;
		line-height: 25px;
		text-align: center;
	}
</style>
<body>
<div th:include="fragments/top::top"></div>
<div class="main-container" id="main-container">
	<div class="main-container-inner">
		<div th:include="fragments/left::left" class="sidebar" id="sidebar"></div>
		<div class="main-content">
			<div class="breadcrumbs" id="breadcrumbs">
				<ul class="breadcrumb">
					<li><i class="icon-home home-icon"></i> 首页</li>
					<li>佣金系统</li>
					<li>佣金信息编辑</li>
				</ul>
			</div>

				<div class="panel panel-default" style="width: 100%">
					<!-- Default panel contents -->
					<div class="panel-heading" style="background-color:#6fb3e0"><span  style="margin-left:45% ">学生基本信息</span><button type="button" class="btn btn-sm btn-primary" style="left: 44%;"  id="student_submit">保存</button></div>
					<!-- List group -->
					<ul class="list-group BasicInformation">
						<li class="list-group-item">
							<shiro:hasRole name="佣金系统_海外操作">
								<input type="hidden" id="permission_commissionOverseas" value="1"/>
							</shiro:hasRole>
							<form method="post" id="edit">
								<div class="row">
									<input type="text" id="studentId" th:value="${studentId}" style="display: none"/>
									<input type="hidden" name="ausAgent" id="ausAgent"/>
									<input type="text" id="id" th:value="${studentId}" name="id" style="display: none"/>
									<div class="input-group col-lg-3">
										<span class="input-group-addon">姓名</span>
										<input type="text" class="form-control" placeholder=" " aria-describedby="basic-addon1" id="studentName" name="studentName" th:value="${student != null}? ${student.studentName}"/>
									</div>
									<div class="input-group col-lg-3">
										<span class="input-group-addon">拼音</span>
										<input type="text" class="form-control" placeholder=" " aria-describedby="basic-addon1" id="spelling" name="spelling" th:value="${student != null}? ${student.spelling}"/>
									</div>
									<div class="input-group col-lg-3">
										<span class="input-group-addon">出生日期</span>
										<input class="form-control" placeholder=" " aria-describedby="basic-addon1" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" th:name="birthday" id="birthday" th:value="${student.birthday != null}? ${#dates.format(student.birthday,'yyyy-MM-dd')}"/>
									</div>
									<div class="input-group col-lg-3">
										<span class="input-group-addon" >获签日期</span>
										<input class="form-control" placeholder=" " aria-describedby="basic-addon1"  th:name="visaDate" id="visaDate" th:value="${student.visaDate != null}? ${#dates.format(student.visaDate,'yyyy-MM-dd')}"  readonly="true" />
									</div>
									<div class="input-group col-lg-3">
										<span class="input-group-addon" >澳际学号</span>
										<input type="text" class="form-control" placeholder=" " aria-describedby="basic-addon1" id="studentNo" name="studentNo" th:value="${student != null}? ${student.studentNo}" />
									</div>

									<div class="input-group col-lg-3">
										<span class="input-group-addon">合同类型</span>
										<select type="text" class="form-control" aria-describedby="basic-addon1" id="contractType" name="contractType">
											<option value="0" th:selected="${student != null}?${student.contractType==null}">请选择</option>
											<option value="1" th:selected="${student != null}?${student.contractType=='1'}">全程合同</option>
											<option value="2" th:selected="${student != null}?${student.contractType=='2'}">单申请合同</option>
											<option value="3" th:selected="${student != null}?${student.contractType=='3'}">单文书合同</option>
											<option value="4" th:selected="${student != null}?${student.contractType=='4'}">单签证学校合同</option>
											<option value="5" th:selected="${student != null}?${student.contractType=='5'}">预科合同</option>
											<!--<option value="5" th:selected="${student != null}?${student.contractType=='5'}">语言培训合同</option>-->
											<!--<option value="6" th:selected="${student != null}?${student.contractType=='6'}">移民送留学合同</option>-->
											<!--<option value="7" th:selected="${student != null}?${student.contractType=='7'}">ALevel合同</option>-->
											<!--<option value="8" th:selected="${student != null}?${student.contractType=='8'}">打包合同</option>-->
										</select>
									</div>
									<div class="input-group col-lg-3">
										<span class="input-group-addon" >代理推荐</span>
										<select type="text" class="form-control" aria-describedby="basic-addon1" name="agentType" id="agentType">
											<option value="0" >请选择</option>
											<option value="1" th:selected="${student.agentType != null}?${student.agentType=='1'}">与代理直接签约</option>
											<option value="2" th:selected="${student.agentType != null}?${student.agentType=='2'}">通过代理与澳际签约</option>
										</select>
									</div>
									<div class="input-group col-lg-3">
										<span class="input-group-addon">登记日期</span>
										<input class="form-control" placeholder=" " aria-describedby="basic-addon1" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" th:name="coeDate" id="coeDate" th:value="${student.coeDate != null}? ${#dates.format(student.coeDate,'yyyy-MM-dd')}"/>
									</div>
									<div class="input-group col-lg-3">
										<span class="input-group-addon" >澳洲代理</span>
										<select type="text" class="form-control" aria-describedby="basic-addon1" name="ausAgentId" id="ausAgentId" onchange="selectTest(this,2)">
											<option value="0">请选择</option>
											<option th:each="item: ${commissionAusAgent}" th:value="${item.id}" th:text="${item.agentName}" th:selected="${student.ausAgentId != null} ? ${student.ausAgentId+'' == item.id+''}"></option>
										</select>
									</div>

									<div class="input-group col-lg-3" >
										<span class="input-group-addon">获签国家</span>
										<!--<input type="text" class="form-control" placeholder=" " aria-describedby="basic-addon1">-->
										<select type="text" class="form-control" aria-describedby="basic-addon1" name="nationId" id="nationId">
											<option value="0">请选择</option>
											<option th:each="item: ${countryList}" th:value="${item.id}" th:text="${item.countryName}" th:selected="${student.nationId != null} ? ${student.nationId == item.id}"></option>
										</select>
									</div>
									<div class="input-group col-lg-3">
										<span class="input-group-addon">学生来源</span>
										<!--<input type="text" class="form-control" placeholder=" " aria-describedby="basic-addon1">-->
										<select type="text" class="form-control" aria-describedby="basic-addon1" name="studentSource" id="studentSource">
											<option value="0" th:selected="${student != null}?${student.studentSource==null}">请选择</option>
											<option value="1" th:selected="${student != null}?${student.studentSource=='1'}">Walk-in</option>student_source
											<option value="2" th:selected="${student != null}?${student.studentSource=='2'}">Sub-agent</option>
											<option value="3" th:selected="${student != null}?${student.studentSource=='3'}">国内澳际</option>
										</select>
									</div>
									<div class="input-group col-lg-3">
										<span class="input-group-addon">代理名称</span>
										<input type="text" class="form-control" placeholder=" " aria-describedby="basic-addon1" id="agentName" name="agentName" th:value="${student != null}?${student.agentName}"/>
									</div>

								</div>
							</form>
						</li>
					</ul>
					<!--<conter>-->
						<!---->
						<!--&lt;!&ndash;<button type="button" class="btn btn-sm btn-primary"  style="left: 47% " id="student_callback">取消</button>&ndash;&gt;-->
					<!--</conter>-->
				</div>


			<div class="panel panel-default" style="width: 100%">
				<!-- Default panel contents -->
				<div class="panel-heading" style="background-color:#6fb3e0"><span  style="margin-left:45% ">佣金信息</span><button type="button" class="btn btn-sm btn-primary" style="left: 46%;"  id="school_submit">添加</button></div>
				<table id="sample-table-2" class="table table-striped table-bordered table-hover">
					<thead>
					<tr>
						<th width="3%">专业类型</th>
						<th width="7%">学校名称</th>
						<th width="7%">专业名称</th>
						<th width="7%">学位名称</th>
						<th width="8%">开学时间</th>
						<th width="3%">invoiceNo</th>
						<th width="4%">invoice金额</th>
						<th width="8%">到账日期</th>
						<th width="4%">到账金额</th>
						<th width="4%">到账GST</th>
						<th width="4%">到账税后金额</th>
						<th width="4%">账户金额</th>
						<th width="6%">结佣状态</th>
						<th width="7%">结佣备注</th>
						<th width="5%">合作机构</th>
						<th width="5%">付款状态</th>
						<th width="5%">付款时间</th>
						<th width="8%">操作</th>
					</tr>
					</thead>
					<tbody>
					<tr th:each="school:${school}">
						<input th:id="schoolId" th:value="${school.id}" type="text" name="schoolId" style="display: none" class="id_class"/>
						<td th:text="${school.id}" th:id="${school.invoiceId == null} ? ${school.id}+'id' :${school.invoiceId}+'id'" style="display: none"></td>
						<td th:if="${school.collegeType == ''}" th:text="''"></td>
						<td th:if="${school.collegeType == null}" th:text="''"></td>
						<td th:if="${school.collegeType == '-1'}" th:text="''"></td>
						<td th:if="${school.collegeType == '0'}" th:text="''"></td>
						<td th:if="${school.collegeType == '1'}" th:text="主课"></td>
						<td th:if="${school.collegeType == '2'}" th:text="语言"></td>
						<td th:if="${school.collegeType == '3'}" th:text="预备"></td>
						<td th:if="${school.collegeType == '4'}" th:text="快捷"></td>
						<td th:if="${school.collegeType == '5'}" th:text="夏校"></td>
						<td th:if="${school.collegeType == '6'}" th:text="桥梁"></td>
						<td th:if="${school.collegeType == '7'}" th:text="topup"></td>
						<td th:text="${school.schoolName}"></td>
						<td th:text="${school.majorName}"></td>
						<td th:text="${school.courseName}"></td>
						<td th:text="${school.startDate != null}?${#dates.format(school.startDate,'yyyy-MM-dd')}"></td>
						<td th:text="${school.invoiceNo}"></td>
						<td th:text="${school.invoiceSum}"></td>
						<td th:text="${school.returnDate != null} ? ${#dates.format(school.returnDate,'yyyy-MM-dd')}"></td>
						<td th:text="${school.actualAmount}"></td>
						<td th:text="${school.accountGst}"></td>
						<td th:text="${school.accountSum}"></td>
						<td th:text="${school.accountMoney}"></td>
						<td th:if="${school.status == null}" th:text="''"></td>
						<td th:if="${school.status == '0'}" th:text="''"></td>
						<td th:if="${school.status == '1'}" th:text="未开始"></td>
						<td th:if="${school.status == '2'}" th:text="进行中"></td>
						<td th:if="${school.status == '3'}" th:text="已结束"></td>
						<td th:if="${school.status == '4'}" th:text="已取消"></td>
						<td><input style='width:75px' type='text' th:if="${school.invoiceId != null}" th:class='${school.invoiceId}' onchange="rowEdit(this, 'invoiceRemark')" th:value='${school.schoolRemark}'/></td>
						<td th:text="${school.agencyName}"></td>
						<!--付款状态-->
						<td th:text="${school.channelReturnStatus}"></td>
						<!--付款时间-->
						<td th:text="${school.paymentDate != null}?${#dates.format(school.paymentDate,'yyyy-MM-dd')}"></td>
						<td>
							<select  type="text" class="form-control operator_class" aria-describedby="basic-addon1" th:id="${school.invoiceId == null} ? ${school.id} :${school.invoiceId}" th:name="${school.invoiceNo}" onclick="removeInvoice()" onchange="operatorChange(this.id,this.name,$('#'+this.id+'id').text())">
								<option value="-1">请选择</option>
								<option value="0" >编辑全部</option>
								<option value="5" >编辑部分</option>
								<option id="editInvoicd" value="4"  th:if="${school.invoiceNo != null}">编辑Invoice</option>
								<option  id="addInvoicd" value="1" th:if="${school.invoiceNo == null}">添加至Invoice</option>
								<!--<option value="2">续加课程</option>-->
								<option value="3">删除</option>
							</select>
						</td>
					</tr>
					</tbody>
				</table>
			</div>


			<!-- /.page-content -->
		</div>

		<div th:include="fragments/bottom::bottom"></div>
	</div>

	<form id="modify">
		<input type="hidden" id="invoiceId" name="invoiceId" />
		<input class="rowEdit" type="hidden" id="invoiceRemark" name="schoolRemark" />
		<input type="hidden" name="type" value="3"/>
	</form>

	<a href="#" id="btn-scroll-up"
	   class="btn-scroll-up btn btn-sm btn-inverse"> <i
			class="icon-double-angle-up icon-only bigger-110"></i>
	</a>
</div>
<!-- /.main-container -->

<!-- Modal备注 -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
	 aria-labelledby="myModalLabel">
	<div class="modal-dialog" role="document">
		<div class="modal-content"></div>
	</div>
</div>
<div th:include="fragments/js::js"></div>
<script th:src="@{/assets/js/chosen.jquery.min.js}"></script>
<script th:src="@{/My97DatePicker/WdatePicker.js}"></script>
<script th:src="@{/assets/js/jquery.inputlimiter.1.3.1.min.js}"></script>
<script th:src="@{/assets/js/jquery.maskedinput.min.js}"></script>
<script th:src="@{/assets/js/bootstrap-tag.min.js}"></script>
<script th:src="@{/assets/js/ace-elements.min.js}"></script>
<!--<script th:src="@{/assets/js/ace.min.js}"></script>-->
<script th:src="@{/business/commission/commissionBranch.js}"></script>
<script th:src="@{/assets/js/jquery.form.js}"></script>
<script th:src="@{/business/common.js}"></script>
<script th:src="@{/assets/js/jquery.validate.min.js}"></script>
<script th:src="@{/assets/js/jquery.validate.zh-CN.js}"></script>
<!-- page specific plugin scripts -->
<script th:src="@{/assets/js/jquery.dataTables.min.js}"></script>
<!--<script th:src="@{/js/bootstrap.js}"></script>-->
<script th:src="@{/assets/js/jquery.dataTables.bootstrap.js}"></script>
<script th:src="@{/assets/js/temp.js}" charset="UTF-8"></script>
<script th:src="@{/business/user/user.js}" charset="UTF-8"></script>
<!--图片查看器-->
<script th:src="@{/assets/js/jquery.colorbox-min.js}"></script>
<script th:src="@{/layer/layer.js}"></script>
<script type="text/javascript">
    <!--
    $(function(){
        $("#student_submit").click(function(){
            $.ajax({
                url: "/commissionManage/editStudent",
                type: "post",
                data: $("#edit").serialize(),
                success: function (data) {
                    console.log(data);
                    if (data) {
                        layer.msg("修改成功!",{time:1500},function(){
                            location.reload(true);
                        })
                    } else {
                        $("#submits").removeAttr("disabled");
                        layer.msg("操作失败",{time:1000})
                    }
                }
            });
        })
        $("#student_callback").click(function(){
            location.reload(true);
        })
        $("#school_submit").click(function(){

            location.href = "/commissionManage/addCommission?studentId="+$("#studentId").val();
        })
    });
    function operatorChange(id,invoiceNo,schoolId){
        //编辑包括院校在内的信息
        if($("#"+id).children("option:selected").val() == 0){
            location.href = "/commissionManage/editCommission?schoolId="+schoolId+"&studentId="+$("#studentId").val();
        }
        //编辑院校以外的信息
        if($("#"+id).children("option:selected").val() == 5){
            location.href = "/commissionManage/editOtherCommission?schoolId="+schoolId+"&studentId="+$("#studentId").val();
        }
        if($("#"+id).children("option:selected").val() == 1){
            location.href = "/invoice/add?schoolIdStr="+schoolId;
        }
        if($("#"+id).children("option:selected").val() == 4){
            location.href = "/invoice/edit?invoiceNo="+invoiceNo;
        }
        if($("#"+id).children("option:selected").val() == 3){
            parent.layer.confirm('确定要删除该条记录吗？', {
                icon: 3,
                btn: ['确认', '取消'],
                btn1: function (index, layero) {
                    $.ajax({
                        url: "/commissionManage/remove",
                        type: "post",
                        data: {schoolId : schoolId},
                        success: function (data) {
                            if (data) {
                                layer.msg('操作成功', {time: 1000});
                                parent.location.reload();
                            } else {
                                layer.msg('操作失败', {time: 1000});
                            }
                        }
                    });
                },
                btn2:function(){
                    parent.location.reload();
                }
            });
        }

    }


    function rowEdit(label, type){
        $(".rowEdit").val(null);
        $("#invoiceId").val(label.getAttribute('class'));
        $("#"+type).val(label.value);
        ajaxSubmit();
    }

    function ajaxSubmit(){
        $.ajax({
            url: "/invoice/updateInvoiceRemarkByInvoiceId",
            type: "post",
            data: $("#modify").serialize(),
            success: function (data) {
                layer.closeAll();
                if (data.result) {
                } else {
                }
            }
        });
    }

	function removeInvoice () {
        if ($("#permission_commissionOverseas").val() == 1) {
            $("#addInvoicd").remove();
            $("#editInvoicd").remove();
        }
    }


    -->
</script>
</body>
</html>
